const p1 = () => {
  return new Promise((resolve, reject ) => {
    setTimeout(() => {
      resolve('P1 OK')
    }, 1000)
  })
}

const p2 = () => {
  return new Promise((resolve, reject ) => {
    setTimeout(() => {
      resolve('P2 OK')
    }, 2000)
  })
}

// generator 函数
// function *fn() {
//   yield p2()
//   yield p1()
// }


// fn1()


// const f = fn();

// f.next().value.then((data => {
//   console.log(data)
//   f.next().value.then(data => {
//     console.log(data)
//   })
// }))



// async 函数
async function fn1() {
  const result1 = await p2()
  await Promise.resolve(1)
  console.log(result1)
  await Promise.reject(123)
  const result2 = await p1()

  console.log(result2)
}

const s = fn1()

s.then(data => {
  console.log('async函数执行完毕')
}).catch(() => {
  console.log('async函数出现问题')
})



const getList = async () => {
  try {
    const resp1 = await axios.get('/XXX')
    try {
      const resp2 = await axios.get('/XXX')
      try {
        const resp3 = await axios.get('/XXX')
      } catch {
      
      }
    } catch {
     
    }
  } catch {
    // 错误日志
  }
  console.log(resp1)
}


getList().catch()

new Promise().then().catch()